home *** CD-ROM | disk | FTP | other *** search
- /*
- ==============================================================================
-
- flyer
-
- ==============================================================================
- */
-
- #include "g_local.h"
- #include "m_flyer.h"
-
- qboolean visible (edict_t *self, edict_t *other);
-
- static int nextmove; // Used for start/stop frames
-
- static int sound_sight;
- static int sound_idle;
- static int sound_pain1;
- static int sound_pain2;
- static int sound_slash;
- static int sound_sproing;
- static int sound_die;
-
-
- void flyer_check_melee(edict_t *self);
- void flyer_loop_melee (edict_t *self);
- void flyer_melee (edict_t *self);
- void flyer_setstart (edict_t *self);
- void flyer_stand (edict_t *self);
- void flyer_nextmove (edict_t *self);
-
-
- void flyer_sight (edict_t *self, edict_t *other)
- {
- gi.sound (self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
- }
-
- void flyer_idle (edict_t *self)
- {
- gi.sound (self, CHAN_VOICE, sound_idle, 1, ATTN_IDLE, 0);
- }
-
- void flyer_pop_blades (edict_t *self)
- {
- gi.sound (self, CHAN_VOICE, sound_sproing, 1, ATTN_NORM, 0);
- }
-
-
- mframe_t flyer_frames_stand [] =
- {
-
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL
- };
- mmove_t flyer_move_stand = {FRAME_hover01, FRAME_hover12, flyer_frames_stand, NULL};
-
-
- mframe_t flyer_frames_walk [] =
- {
-
- ai_walk, 5, NULL,
- ai_walk, 5, NULL,
- ai_walk, 5, NULL,
- ai_walk, 5, NULL,
- ai_walk, 5, NULL,
- ai_walk, 5, NULL,
- ai_walk, 5, NULL,
- ai_walk, 5, NULL,
- ai_walk, 5, NULL,
- ai_walk, 5, NULL,
- ai_walk, 5, NULL,
- ai_walk, 5, NULL
- };
- mmove_t flyer_move_walk = {FRAME_fly01, FRAME_fly12, flyer_frames_walk, NULL};
-
- mframe_t flyer_frames_run [] =
- {
-
-
- ai_run, 10, NULL,
- ai_run, 10, NULL,
- ai_run, 10, NULL,
- ai_run, 10, NULL,
- ai_run, 10, NULL,
- ai_run, 10, NULL,
- ai_run, 10, NULL,
- ai_run, 10, NULL,
- ai_run, 10, NULL,
- ai_run, 10, NULL,
- ai_run, 10, NULL,
- ai_run, 10, NULL
- };
- mmove_t flyer_move_run = {FRAME_fly01, FRAME_fly12, flyer_frames_run, NULL};
-
- void flyer_run (edict_t *self)
- {
- if (self->monsterinfo.aiflags & AI_STAND_GROUND)
- self->monsterinfo.currentmove = &flyer_move_stand;
- else
- self->monsterinfo.currentmove = &flyer_move_run;
- }
-
- void flyer_walk (edict_t *self)
- {
- self->monsterinfo.currentmove = &flyer_move_walk;
- }
-
- void flyer_stand (edict_t *self)
- {
- self->monsterinfo.currentmove = &flyer_move_stand;
- }
-
- mframe_t flyer_frames_start [] =
- {
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, flyer_nextmove
- };
- mmove_t flyer_move_start = {FRAME_hover01, FRAME_hover06, flyer_frames_start, NULL};
-
- mframe_t flyer_frames_stop [] =
- {
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, flyer_nextmove
- };
- mmove_t flyer_move_stop = {FRAME_hover06, FRAME_hover12, flyer_frames_stop, NULL};
-
- void flyer_stop (edict_t *self)
- {
- self->monsterinfo.currentmove = &flyer_move_stop;
- }
-
- void flyer_start (edict_t *self)
- {
- self->monsterinfo.currentmove = &flyer_move_start;
- }
-
-
- mframe_t flyer_frames_rollright [] =
- {
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
- };
- mmove_t flyer_move_rollright = {FRAME_bankr01, FRAME_bankr12, flyer_frames_rollright, NULL};
-
- mframe_t flyer_frames_rollleft [] =
- {
-
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
- };
- mmove_t flyer_move_rollleft = {FRAME_bankl01, FRAME_bankl12, flyer_frames_rollleft, NULL};
-
- mframe_t flyer_frames_pain3 [] =
- {
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
- };
- mmove_t flyer_move_pain3 = {FRAME_hover01, FRAME_hover04, flyer_frames_pain3, flyer_run};
-
- mframe_t flyer_frames_pain2 [] =
- {
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
- };
- mmove_t flyer_move_pain2 = {FRAME_bankr01, FRAME_bankr04, flyer_frames_pain2, flyer_run};
-
- mframe_t flyer_frames_pain1 [] =
- {
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
- };
- mmove_t flyer_move_pain1 = {FRAME_hover01, FRAME_hover09, flyer_frames_pain1, flyer_run};
-
- mframe_t flyer_frames_defense [] =
- {
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL, // Hold this frame
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
- };
- mmove_t flyer_move_defense = {FRAME_hover01, FRAME_hover06, flyer_frames_defense, NULL};
-
- mframe_t flyer_frames_bankright [] =
- {
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
- };
- mmove_t flyer_move_bankright = {FRAME_bankr01, FRAME_bankr12, flyer_frames_bankright, NULL};
-
- mframe_t flyer_frames_bankleft [] =
- {
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
- };
- mmove_t flyer_move_bankleft = {FRAME_bankl01, FRAME_bankl12, flyer_frames_bankleft, NULL};
-
-
- void flyer_fire (edict_t *self, int flash_number)
- {
- vec3_t forward, right;
- vec3_t start;
- vec3_t end;
- vec3_t dir;
- vec3_t from;
- int damage = 15;
-
- trace_t tr;
-
- AngleVectors (self->s.angles, forward, right, NULL);
- G_ProjectSource (self->s.origin, monster_flash_offset[flash_number], forward, right, start);
- VectorCopy (self->s.origin, start);
- VectorCopy (self->enemy->s.origin, end);
- end[2] += self->enemy->viewheight;
- VectorSubtract (end, start, dir);
-
- VectorAdd(start, right, start);
- end[2] = end[2] - 32;
- if(self->spawnflags & 1)
- start[2] = start[2] + 34;
-
- VectorCopy (start, from);
- tr = gi.trace (from, NULL, NULL, end, self, MASK_SHOT);
- VectorCopy (tr.endpos, from);
-
-
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_SHOTGUN);
- gi.WritePosition (start);
- gi.WritePosition (end);
- gi.multicast (start, MULTICAST_PHS);
-
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_BLASTER);
- gi.WritePosition (end);
- gi.WriteDir (tr.plane.normal);
- gi.multicast (end, MULTICAST_PVS);
-
- gi.sound (self, CHAN_VOICE, sound_slash, 1, ATTN_NORM, 0);
-
- if ((tr.ent != self) && (tr.ent->takedamage))
- T_Damage (tr.ent, self, self, dir, tr.endpos, tr.plane.normal, damage, 0, 0, MOD_HYPERBLASTER);
- else if (!((tr.surface) && (tr.surface->flags & SURF_SKY)))
- {
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_SCREEN_SPARKS);
- gi.WritePosition (tr.endpos);
- gi.WriteDir (tr.plane.normal);
- gi.multicast (self->s.origin, MULTICAST_PVS);
- }
-
- }
-
- void flyer_fireleft (edict_t *self)
- {
- flyer_fire (self, MZ2_FLYER_BLASTER_1);
- }
-
- void flyer_fireright (edict_t *self)
- {
- flyer_fire (self, MZ2_FLYER_BLASTER_2);
- }
-
-
- mframe_t flyer_frames_attack2 [] =
- {
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, -10, flyer_fireleft,
- ai_charge, 0, NULL,
- ai_charge, -10, flyer_fireright,
- ai_charge, -0, NULL,
- ai_charge, -10, flyer_fireleft,
- ai_charge, -0, NULL,
- ai_charge, -10, flyer_fireright,
- ai_charge, -0, NULL,
- ai_charge, 0, NULL,
-
- ai_charge, 0, NULL
- };
- mmove_t flyer_move_attack2 = {FRAME_hover01, FRAME_hover12, flyer_frames_attack2, flyer_run};
-
-
- void flyer_slash_left (edict_t *self)
- {
- vec3_t aim;
-
- VectorSet (aim, MELEE_DISTANCE, self->mins[0], 0);
- fire_hit (self, aim, 5, 0);
- gi.sound (self, CHAN_WEAPON, sound_slash, 1, ATTN_NORM, 0);
- }
-
- void flyer_slash_right (edict_t *self)
- {
- vec3_t aim;
-
- VectorSet (aim, MELEE_DISTANCE, self->maxs[0], 0);
- fire_hit (self, aim, 5, 0);
- gi.sound (self, CHAN_WEAPON, sound_slash, 1, ATTN_NORM, 0);
- }
-
- mframe_t flyer_frames_start_melee [] =
- {
- ai_charge, 0, flyer_pop_blades,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL
- };
- mmove_t flyer_move_start_melee = {FRAME_fly01, FRAME_fly06, flyer_frames_start_melee, flyer_loop_melee};
-
- mframe_t flyer_frames_end_melee [] =
- {
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL
- };
- mmove_t flyer_move_end_melee = {FRAME_fly10, FRAME_fly12, flyer_frames_end_melee, flyer_run};
-
-
- mframe_t flyer_frames_loop_melee [] =
- {
- ai_charge, 0, NULL, // Loop Start
- ai_charge, 0, NULL,
- ai_charge, 0, flyer_slash_left, // Left Wing Strike
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, flyer_slash_right, // Right Wing Strike
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL // Loop Ends
-
- };
- mmove_t flyer_move_loop_melee = {FRAME_fly01, FRAME_fly12, flyer_frames_loop_melee, flyer_check_melee};
-
- void flyer_loop_melee (edict_t *self)
- {
- /* if (random() <= 0.5)
- self->monsterinfo.currentmove = &flyer_move_attack1;
- else */
- self->monsterinfo.currentmove = &flyer_move_loop_melee;
- }
-
-
-
- void flyer_attack (edict_t *self)
- {
- /* if (random() <= 0.5)
- self->monsterinfo.currentmove = &flyer_move_attack1;
- else */
- self->monsterinfo.currentmove = &flyer_move_attack2;
- }
-
- void flyer_setstart (edict_t *self)
- {
- nextmove = ACTION_run;
- self->monsterinfo.currentmove = &flyer_move_start;
- }
-
- void flyer_nextmove (edict_t *self)
- {
- if (nextmove == ACTION_attack1)
- self->monsterinfo.currentmove = &flyer_move_start_melee;
- else if (nextmove == ACTION_attack2)
- self->monsterinfo.currentmove = &flyer_move_attack2;
- else if (nextmove == ACTION_run)
- self->monsterinfo.currentmove = &flyer_move_run;
- }
-
- void flyer_melee (edict_t *self)
- {
- // flyer.nextmove = ACTION_attack1;
- // self->monsterinfo.currentmove = &flyer_move_stop;
- self->monsterinfo.currentmove = &flyer_move_start_melee;
- }
-
- void flyer_check_melee(edict_t *self)
- {
- if (range (self, self->enemy) == RANGE_MELEE)
- if (random() <= 0.8)
- self->monsterinfo.currentmove = &flyer_move_loop_melee;
- else
- self->monsterinfo.currentmove = &flyer_move_end_melee;
- else
- self->monsterinfo.currentmove = &flyer_move_end_melee;
- }
-
- void flyer_pain (edict_t *self, edict_t *other, float kick, int damage)
- {
- int n;
-
- if (self->health < (self->max_health / 2))
- self->s.skinnum = 1;
-
- if (level.time < self->pain_debounce_time)
- return;
-
- self->pain_debounce_time = level.time + 3;
- if (skill->value == 3)
- return; // no pain anims in nightmare
-
- n = rand() % 3;
- if (n == 0)
- {
- gi.sound (self, CHAN_VOICE, sound_pain1, 1, ATTN_NORM, 0);
- self->monsterinfo.currentmove = &flyer_move_pain1;
- }
- else if (n == 1)
- {
- gi.sound (self, CHAN_VOICE, sound_pain2, 1, ATTN_NORM, 0);
- self->monsterinfo.currentmove = &flyer_move_pain2;
- }
- else
- {
- gi.sound (self, CHAN_VOICE, sound_pain1, 1, ATTN_NORM, 0);
- self->monsterinfo.currentmove = &flyer_move_pain3;
- }
- }
-
-
- void flyer_die(edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
- {
- gi.sound (self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0);
- BecomeExplosion1(self);
- }
-
-
- /*QUAKED monster_flyer (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
- */
- void SP_monster_saucer (edict_t *self)
- {
- if (deathmatch->value)
- {
- G_FreeEdict (self);
- return;
- }
-
- // fix a map bug in jail5.bsp
- if (!stricmp(level.mapname, "jail5") && (self->s.origin[2] == -104))
- {
- self->targetname = self->target;
- self->target = NULL;
- }
-
- sound_sight = gi.soundindex ("flyer/flysght1.wav");
- sound_idle = gi.soundindex ("flyer/flysrch1.wav");
- sound_pain1 = gi.soundindex ("flyer/flypain1.wav");
- sound_pain2 = gi.soundindex ("flyer/flypain2.wav");
- sound_slash = gi.soundindex ("martian/shoot1.wav");
- sound_sproing = gi.soundindex ("martian/shoot2.wav");
- sound_die = gi.soundindex ("flyer/flydeth1.wav");
-
- if(self->spawnflags & 1)
- self->s.modelindex = gi.modelindex ("models/monsters/martian_warship/tris.md2");
- else
- self->s.modelindex = gi.modelindex ("models/monsters/martian_saucer/tris.md2");
- if(self->spawnflags & 1)
- {
- VectorSet (self->mins, -64, -64, -24);
- VectorSet (self->maxs, 64, 64, 64);
- }
- else
- {
- VectorSet (self->mins, -64, -64, 16);
- VectorSet (self->maxs, 64, 64, 156);
- }
- self->movetype = MOVETYPE_STEP;
- self->solid = SOLID_BBOX;
- self->classname = "monster_saucer";
-
- if(self->spawnflags & 1)
- self->s.sound = gi.soundindex ("flyer/flyidle1.wav");
- else
- self->s.sound = gi.soundindex ("martian/saucer.wav");
-
- self->health = 250;
- self->mass = 250;
-
- self->pain = flyer_pain;
- self->die = flyer_die;
-
- self->monsterinfo.stand = flyer_stand;
- self->monsterinfo.walk = flyer_walk;
- self->monsterinfo.run = flyer_run;
- self->monsterinfo.attack = flyer_attack;
- self->monsterinfo.melee = flyer_melee;
- self->monsterinfo.sight = flyer_sight;
- self->monsterinfo.idle = flyer_idle;
-
- gi.linkentity (self);
-
- self->monsterinfo.currentmove = &flyer_move_stand;
- self->monsterinfo.scale = MODEL_SCALE;
-
- flymonster_start (self);
- }
-